home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / BLOCKOUT.C < prev    next >
C/C++ Source or Header  |  1992-09-24  |  3KB  |  118 lines

  1. /*$Author:   DCODY  $*/
  2. /*$Date:   24 Sep 1992 08:58:52  $*/
  3. /*$Header:   X:/sccs/pcmapps/blockout.c_v   1.4   24 Sep 1992 08:58:52   DCODY  $*/
  4. /*$Log:   X:/sccs/pcmapps/blockout.c_v  $
  5.  * 
  6.  *    Rev 1.4   24 Sep 1992 08:58:52   DCODY
  7.  * changed MVGetHardware to mvGetHardware
  8.  * 
  9.  *    Rev 1.3   20 Jul 1992 11:38:34   DCODY
  10.  * call to mvGetHWVersion now uses active I/O address detection.
  11.  * 
  12.  *    Rev 1.2   13 Jul 1992 19:05:28   DCODY
  13.  * removed initmvsound call. changed pcmstate to add 8 bit pcm parm.
  14.  * 
  15.  *    Rev 1.1   23 Jun 1992 16:09:34   DCODY
  16.  * pas2 update...
  17.  * 
  18.  *    Rev 1.0   15 Jun 1992 09:26:26   BCRANE
  19.  * Initial revision.
  20. */
  21. /*$Logfile:   X:/sccs/pcmapps/blockout.c_v  $*/
  22. /*$Modtimes$*/
  23. /*$Revision:   1.4  $*/
  24. /*$Workfile:   blockout.c  $*/
  25.  
  26.  
  27. /* simple PCM play program - reads the disk & sends the data to the DMA */
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <malloc.h>
  32. #include <signal.h>
  33. #include "pcmio.h"
  34. #include "common.h"
  35.  
  36. char OurData[4096];
  37. extern int DMARunning;
  38.  
  39. main(argc,argv)
  40.     int argc;
  41.     char *argv[];
  42. {
  43. FILE *f;
  44. int n;
  45.  
  46.     /* abort if the hardware is not found                                */
  47.  
  48.         if (mvGetHWVersion(USE_ACTIVE_ADDR) == -1) {
  49.             printf ("\aThe Pro AudioSpectrum hardware is not installed!\n");
  50.             exit(1);
  51.         }
  52.  
  53.     /* if not enough parameters, bomb out...                            */
  54.  
  55.         if (argc < 2) {
  56.             printf ("to use: >BLOCKOUT [FILE.EXT]\n");
  57.             exit(0);
  58.         }
  59.  
  60.     /* open the input file                                                */
  61.  
  62.         if ((f = fopen(argv[1],"rb")) == 0) {
  63.             printf ("to use: >BLOCKOUT [FILE.EXT]\n");
  64.             exit(0);
  65.         }
  66.  
  67.     /* open the PCM code                                                */
  68.  
  69.         if (OpenPCMBuffering(-1,-1,16,4)) {
  70.             printf ("\aCannot setup the PCM software!\n");
  71.             exit(1);
  72.         }
  73.  
  74.     /* setup the sample rate & stereo flag                                */
  75.  
  76.         PCMState (22050L, 0, 0, 8);     /* 22050 khz, mono, 8 bit pcm    */
  77.  
  78.     /* if the DMA engine starts, keep the data moving from the disk!    */
  79.  
  80.         n = fread (OurData, 1, 4096, f);
  81.         while (n < 4096)
  82.             OurData[n++] = 0x80;
  83.  
  84.         if (StartBlockOutput(OurData)) {
  85.  
  86.             n = fread (OurData, 1, 4096, f);
  87.             while (n < 4096)
  88.                 OurData[n++] = 0x80;
  89.  
  90.             while (!feof(f)) {
  91.  
  92.                 /* if the new block is passed in, load more...            */
  93.  
  94.                     if (ContinueBlockOutput(OurData)) {
  95.  
  96.                         /* read the next block of data                    */
  97.  
  98.                             n = fread (OurData, 1, 4096, f);
  99.                             while (n < 4096)
  100.                                 OurData[n++] = 0x80;
  101.                     }
  102.             }
  103.  
  104.             /* EOF now, wait for the DMA to quit...                     */
  105.  
  106.             while (DMARunning) ;
  107.  
  108.         }
  109.  
  110.     /* exit to DOS                                                        */
  111.  
  112.         ClosePCMBuffering();
  113.         close (f);
  114.         exit(0);
  115. }
  116.  
  117.  
  118.